|
|
|
|
|
|
|
Instead of using a single polynomial to fit a set of data points, you can use two polynomials to define parametric equations X(t) and Y(t) to fit the points. Parametric equations allow a curve far more flexibility than a simple polynomial does. A parametric curve can move straight up or even turn back and cross itself like the curve shown in Figure 11.13. The following sections describe different ways you can create parametric curves that fit a set of data points. |
|
|
|
|
|
|
|
|
Hermite curves use cubic (degree-three polynomial) parametric equations of the form: |
|
|
|
 |
|
|
|
|
X(t) = ax * t3 + bx * t2 + cx * t + dx Y(t) = ay * t3 + by * t2 + cy * t + dy |
|
|
|
|
|
|
|
|
for appropriate constants ax, bx, cx, dx, ay, by, cy, and dy. Using these equations, you can connect two points with a curve that has a specified slope at each end. You can use several Hermite curves with matching slopes to connect more than two points. |
|
|
|
|
|
|
|
|
In the Hermite form, you specify two endpoints for the curve and the tangent vectors at the two endpoints. The curve should pass through the two endpoints heading in the directions of the tangent vectors. |
|
|
|
|
|
|
|
|
Suppose the endpoints are at coordinates (Ex1, Ey1) and (Ex2, Ey2), and that the tangent vectors are <Vx1, Vy1> and <Vx2, Vy2>. Now suppose you want to create a parametric equation X(t) for the X coordinate of the points on the curve with 0 <= t <= 1. If the |
|
|
|
|
|
|
|
|
Figure 11.13
The parametric curve X(t) = t3 t, Y(t) = t2. |
|
|
|
|
|